import { fileURLToPath, URL } from 'node:url'
import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// https://vite.dev/config/
export default defineConfig({
   // 服务端渲染
   server: {
    port: 8080, // 端口号
    host: "0.0.0.0",
    // 本地跨域代理. 目前注释的原因：暂时没有用途，server 端已经支持跨域
    proxy: {
      ['/admin-api']: {
        target: "http://192.168.6.58:48080",
        ws: false,
        changeOrigin: true,
      },
    },
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    })
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src')
    }
  },
  build: {
    outDir: 'api-dbg'
  },
  base: '/api-dbg/'
})
